<template>
  <div class="orderALL">
    <div class="order">
      <div
        v-show="!item.flag"
        class="orderItem"
        v-for="(item, index) in orders"
        :key="index"
      >
        <div class="head">
          <div><span class="iconfont lv icon-lvyou"></span> 门票</div>
          <div v-if="!item.flag" style="color: orange">待支付</div>
          <div v-if="item.flag" style="color: orange">已支付</div>
        </div>
        <div class="center">
          <div class="cardN">{{ item.cardName }}</div>
          <div>
            <div><span>￥</span>{{ item.prize }}</div>
            <div class="grey" style="float: right">x{{ item.num }}</div>
          </div>
        </div>
        <div class="grayLine"></div>
        <div class="lineDown">
          <div v-if="!item.flag" class="fr" @click="payNow(index)">
            立即支付
          </div>
          <div v-if="item.flag" class="fr">已支付</div>
          <div class="fr" @click.stop="del(index)">删除订单</div>
        </div>
      </div>
      <div v-show="this.$store.state.orderDatas.length == 0">
        <div class="box">
          <img src="../../public/imgs/noneBox.png" alt="" />
        </div>
        <div class="grey">你没有待支付的订单哟~</div>
      </div>
    </div>
  </div>
</template>

<style lang = "less">
.order {
  height: 100vh;
  width: 100vw;
  background: rgb(240, 242, 245);
  .lv {
    color: rgb(0, 212, 227);
  }
  .grey {
    color: grey;
  }
  .grayLine {
    height: 1px;
    background: #e0e0e0;
    margin: 10px;
  }

  .headers {
    padding: 10px;
    color: white;
    background: rgb(76, 192, 228);
  }
  .bar {
    display: flex;
    padding-top: 10px;
    margin: 10px;
    margin-top: 0;
    justify-content: space-between;
    color: gray;
    div {
      margin: 10px 0;
      background: white;
      padding: 6px 20px;
      border-radius: 30px;
      font-size: 12px;
    }
    .active {
      background-color: rgb(191, 244, 247);
      border: 1px solid rgb(0, 212, 227);
      color: rgb(0, 212, 227);
    }
  }
  .box {
    margin: 0 auto;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .orderItem {
    margin: 10px;
    border-radius: 5px;
    background-color: white;
    .head {
      padding-top: 10px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin: 10px 20px;
      background-color: white;
    }
    .center {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin: 10px 20px;
      background-color: white;
      .cardN {
        width: 80%;
        text-align: left;
      }
    }
    .lineDown {
      padding: 0 0 10px 10px;
      /* padding-right: 0; */
      display: flex;
      background-color: white;
      justify-content: flex-end;
      border-radius: 5px;
      .fr {
        font-size: 14px;
        margin-right: 10px;
        border: 1px solid #e0e0e0;
        color: gray;
        border-radius: 10px;
        padding: 1px 10px;
      }
    }
  }
}
</style>

<script>
import Vue from "vue";
export default {
  data() {
    return {
      payFlag: false,
      bars: [
        { text: "全部", con: "active", flag: true },
        { text: "待出行", con: "", flag: false },
        { text: "待支付", con: "", flag: false },
        { text: "退款/售后", con: "", flag: false },
      ],
      flag: [
        {
          flag: true,
        },
      ],
      newOrders: [
        {
          cardName: "",
          prize: 0,
          num: 1,
          flagPay: false,
        },
      ],
      orders: [],
    };
  },
  methods: {
    del(index) {
      this.$store.commit("del", { index });
    },
    payNow(index) {
      this.orders[index].flag = true;
      this.$store.commit("change", { index });
    },
    act(index) {
      for (let i = 0; i < this.bars.length; i++) {
        this.bars[i].con = "";
        this.bars[i].flag = false;
      }
      this.bars[index].con = "active";
      this.bars[index].flag = true;
    },
  },
  components: {},
  created() {
    this.orders = this.$store.state.orderDatas;
    if (this.$store.state.orderDatas.length == 0) {
      Vue.set(this.flag, 0, { flag: true });
    } else {
      Vue.set(this.flag, 0, { flag: false });
    }
  },
};
</script>